# Contributor: Celeste <cielesti@protonmail.com>
# Maintainer: Celeste <cielesti@protonmail.com>
pkgname=ocaml-iri
pkgver=1.0.0
pkgrel=0
pkgdesc="Implementation of Internationalized Resource Identifiers (IRIs)"
url="https://framagit.org/zoggy/ocaml-iri"
arch="all !riscv64 !loongarch64" # ocaml
license="LGPL-3.0-only"
depends_dev="
	$pkgname=$pkgver-r$pkgrel
	ocaml-sedlex-dev
	ocaml-uunf-dev
	ocaml-uutf-dev
	"
makedepends="
	$depends_dev
	dune
	ocaml
	"
subpackages="$pkgname-dev"
source="https://zoggy.frama.io/ocaml-iri/releases/ocaml-iri-$pkgver.tar.bz2"

# 32-bit archs
case "$CARCH" in
	arm*|x86) options="$options textrels" ;;
esac

build() {
	dune build --release --verbose
}

check() {
	dune runtest --build-dir=.testenv --verbose
}

package() {
	dune install --destdir="$pkgdir" --docdir=/.omit
}

dev() {
	default_dev

	cd "$pkgdir"

	local path; find usr/lib/ocaml \( \
			-name '*.cmt' -o \
			-name '*.cmti' -o \
			-name '*.ml' -o \
			-name '*.mli' \
		\) | while read -r path
	do
		amove "$path"
	done
}

prepare_py_provides() {
	local datadir="${subpkgdir:-$pkgdir}"
	local pkgbasedir=${pkgbasedir:-"$startdir/pkg"}
	local controldir="$pkgbasedir"/.control.${subpkgname:-$pkgname}

	options_has "!tracedeps" && return 0

	ocaml4-abuild-find provides \
		"$datadir"/usr/lib/ocaml \
		"$controldir" \
		"$pkgver-r$pkgrel"
}

scan_python3_dependency() {
	local controldir="$2" datadir="$3"

	ocaml4-abuild-find requires \
		"$datadir"/usr/lib/ocaml \
		"$controldir"
}

sha512sums="
dad58975f1f601a56c113c5646a7b3c29ae5eb1c505e17c6120f492634d867d961f3f5cda8198b6e2a3cd84d23b04e4d230683a325c3935da1655c129a328eee  ocaml-iri-1.0.0.tar.bz2
"
